package com.zz.ecommerce.synchronousBooks;

import com.zz.ecommerce.common.CommonDao;
import com.zz.ecommerce.common.GridRequest;
import com.zz.ecommerce.common.GridResult;
import com.zz.ecommerce.synchronousBooks.bean.TCbecBookEnt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@RequestMapping("/synchronousBooks")
public class TCbecBookEntController {
    @Autowired
    CommonDao commonDao;

    @RequestMapping(value = "TCbecBookEntManager", method = RequestMethod.GET)
    public String TCbecBookEntManager() {
        return "synchronousBooks/tcbecbookent_manager";
    }

    @RequestMapping(value = "qryTCbecBookEntPage", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public GridResult<TCbecBookEnt> qryTCbecBookEntPage(GridRequest gridRequest, TCbecBookEnt tCbecBookEnt) {
        List<TCbecBookEnt> list = commonDao.pageWhere("T_CBEC_BOOK_ENT", tCbecBookEnt, gridRequest.getStart(), gridRequest.getEnd(), "", "");
        long count = commonDao.countWhere("T_CBEC_BOOK_ENT", tCbecBookEnt, "");
        return new GridResult<TCbecBookEnt>(list, gridRequest, count);
    }

    @RequestMapping(value = "saveTCbecBookEnt", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public String saveTCbecBookEnt(HttpSession session, TCbecBookEnt tCbecBookEnt) {
        return "success";
    }

    @RequestMapping(value = "getTCbecBookEntDetail", method = {RequestMethod.GET, RequestMethod.POST})
    public String getTCbecBookEntDetail(TCbecBookEnt tCbecBookEnt, ModelMap modelMap) {
        TCbecBookEnt tCbecBookEntDetail = (TCbecBookEnt) commonDao.qryOneCommon("T_CBEC_BOOK_ENT", tCbecBookEnt, "");
        modelMap.put("tCbecBookEnt", tCbecBookEntDetail);
        return "synchronousBooks/tcbecbookent_detail";
    }
}
